﻿using JESAI.Application.Abstractions.Admin;
using JESAI.Application.Abstractions.Admin.Dtos.Post;
using JESAI.Application.Abstractions.Admin.Dtos.Role;
using JESAI.Application.Abstractions.Dtos;
using JESAI.Application.Service.Admin;
using JESAI.Framework.Filters;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace JESAI.Platform.WebApi.Controllers.Admin
{
    [ApiController]
    [Authorize("permission")]
    [IgnoreResultHandlerAttribute]
    public class PostController : ControllerBase
    {
        private readonly IPostService _postService;

        public PostController(IPostService postService)
        {
            _postService = postService;
        }

        /// <summary>
        /// 设置岗位信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("/Post/SetPost")]
        public async Task<BaseOutput> SetPost([FromBody] SetPostInput input)
        {
            await _postService.UpdateOrInsert(input);
            return new BaseOutput { };
        }

        [HttpGet("/Post/DeletePosts")]
        public async Task<BaseOutput> DeletePosts(string[] ids)
        {
            await _postService.DeletePosts(ids);
            return new BaseOutput { };
        }

        [HttpGet("/Post/DeletePost")]
        public async Task<BaseOutput> DeletePost(string id)
        {
            await _postService.DeletePost(id);
            return new BaseOutput { };
        }

        /// <summary>
        /// 查询岗位列表
        /// </summary>
        /// <returns></returns>
        [HttpGet("/Post/QueryPagePosts")]
        public async Task<BasePageOutput<List<QueryPostDto>>> QueryPagePosts([FromQuery] QueryPostPageInput input)
        {
            var result = await _postService.QueryPagePosts(input);
            return result;
        }
    }
}
